home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / ugly / prginfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  4.7 KB  |  176 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1993-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. /*
  21.  * ugly/prginfo.c
  22.  *
  23.  * ugly program info functions
  24.  *
  25.  * Copyright (C) 1994,95,96  Thomas Aglassinger
  26.  *
  27.  * This program is free software; you can redistribute it and/or modify
  28.  * it under the terms of the GNU General Public License as published by
  29.  * the Free Software Foundation; either version 2 of the License, or
  30.  * (at your option) any later version.
  31.  *
  32.  * This program is distributed in the hope that it will be useful,
  33.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35.  * GNU General Public License for more details.
  36.  *
  37.  * You should have received a copy of the GNU General Public License
  38.  * along with this program; if not, write to the Free Software
  39.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  40.  *
  41.  * updated: 27-Oct-1996
  42.  * created:  3-Jul-1994
  43.  *
  44.  *=========================================================
  45.  * TODO:
  46.  * - set_prginfo()-macro: replace "name" by "( name ? name : argv[0] )"
  47.  *
  48.  */
  49.  
  50. /* ANSI includes */
  51. #include <stdlib.h>
  52. #include <stdio.h>
  53. #include <string.h>
  54.  
  55. #include "utypes.h"
  56.  
  57. #define SIZE_DATESTR 24
  58.  
  59. #ifdef AMIGA
  60. /* system version string on amiga systems */
  61. STRPTR amiga_version = "";
  62. #endif
  63.  
  64. /*
  65.  * local global vars
  66.  */
  67. STRPTR pi_progname = NULL;      /* exported */
  68. STRPTR pi_authname = NULL;
  69. int pi_version = 0;
  70. int pi_release = 0;
  71. int pi_revision = 0;
  72. char pi_rel_date[SIZE_DATESTR];
  73. STRPTR pi_rel_time = NULL;
  74. STRPTR pi_descript = NULL;
  75. STRPTR pi_copystat = NULL;
  76.  
  77. STRPTR pi_dt_day = NULL;
  78. STRPTR pi_dt_month = NULL;
  79. STRPTR pi_dt_year = NULL;
  80.  
  81. /*
  82.  * call_set_prginfo
  83.  *
  84.  * set pi_xxx vars; called by macro set_info()
  85.  *
  86.  */
  87. void call_set_prginfo(STRPTR name, STRPTR auth, int ver, int rel, int rev,
  88.         STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus)
  89. {
  90.     pi_progname = name;
  91.     pi_authname = auth;
  92.     pi_version = ver;
  93.     pi_release = rel;
  94.     pi_revision = rev;
  95.     pi_rel_time = rel_time;
  96.     pi_descript = infostr;
  97.     pi_copystat = copystatus;
  98.  
  99.     strncpy(pi_rel_date, rel_date, SIZE_DATESTR);
  100.     pi_rel_date[3] = '\0';
  101.     pi_rel_date[6] = '\0';
  102.     pi_dt_month = pi_rel_date;
  103.     pi_dt_day = &(pi_rel_date[4]);
  104.     if (pi_dt_day[0] == ' ')
  105.         pi_dt_day++;
  106.     pi_dt_year = &(pi_rel_date[7]);
  107. }
  108.  
  109. /*
  110.  * call_set_prginfo2
  111.  *
  112.  * set pi_xxx vars; called by macro set_info()
  113.  *
  114.  * NOTE: this version expects date "DD.MM.YY"
  115.  */
  116. void call_set_prginfo2(STRPTR name, STRPTR auth, int ver, int rel, int rev,
  117.         STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus)
  118. {
  119.     STRPTR monthName[] =
  120.     {"XXX", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  121.     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  122.  
  123.     pi_progname = name;
  124.     pi_authname = auth;
  125.     pi_version = ver;
  126.     pi_release = rel;
  127.     pi_revision = rev;
  128.     pi_rel_time = rel_time;
  129.     pi_descript = infostr;
  130.     pi_copystat = copystatus;
  131.  
  132.     strncpy(pi_rel_date, rel_date, SIZE_DATESTR);
  133.  
  134.     /* eval day */
  135.     pi_dt_day = pi_rel_date;
  136.  
  137.     /* eval month */
  138.     pi_dt_month = strchr(pi_rel_date, '.');
  139.     pi_dt_month[0] = '\0';
  140.     pi_dt_month++;
  141.  
  142.     /* eval year */
  143.     pi_dt_year = strchr(pi_dt_month, '.');
  144.     pi_dt_year[0] = '\0';
  145.     pi_dt_year++;
  146.  
  147.     /* convert numeric month */
  148.     pi_dt_month = monthName[strtol(pi_dt_month, NULL, 10)];
  149. }
  150.  
  151. /*
  152.  * fprintf_prginfo
  153.  *
  154.  * display program information
  155.  *
  156.  */
  157. int fprintf_prginfo(FILE * stream)
  158. {
  159.     int err = 0;
  160.  
  161.     err = fprintf(stream, "%s - %s, v%d.%d",
  162.                   pi_progname, pi_descript,     /* name & description */
  163.                   pi_version, pi_release);      /* version */
  164.     if (pi_revision)
  165.         err += fprintf(stream, ".%d",   /* revision */
  166.                        pi_revision);
  167.     err += fprintf(stream, " (%s-%s-%s)\n",     /* date */
  168.                    pi_dt_day, pi_dt_month, pi_dt_year);
  169.     err += fprintf(stream, "(C) %s. %s\n",      /* copyright */
  170.                    pi_authname, pi_copystat);
  171.  
  172.     return (err);
  173.  
  174. }
  175.  
  176.